package com.xd.springboot.dao;

import com.xd.springboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //基于注解
    @Select("select * from user where id = #{id}")
    @Results({
            @Result(property = "username", column = "user_name"),
            @Result(property = "password", column = "password")
    })
    User getUser(Long id);


    @Select("select * from user where id = #{id} and user_name=#{name}")
    User getUserByIdAndName(@Param("id") Long id, @Param("name") String username);


    @Select("select * from user")
    List<User> getAll();

    @Insert("insert into user (id,user_name,password) values(#{id},#{username},#{password})")
    Integer insertUser(User user);


    //基于xml配置文件
    User getUserByName(String username);
}
